import * as echarts from 'echarts';
import map from '@/assets/echarts/zhejiang.json';



export function initMap() {
  echarts.registerMap('zhejiang', map);
  // 注册矢量地图数据
  const option = {
    visualMap: { // 视觉映射组件
      show: false,
      inverse: true, // 反转
      top: '70%',
      bottom: '2%',
      left: '10%',
      textStyle: {
        fontsize: 12
      },
      splitList: [ // 自定义范围
        {
          start: 0,
          end: 100
        }, {
          start: 100,
          end: 200
        }, {
          start: 200,
          end: 300
        }, {
          start: 300,
          end: 400
        }, {
          start: 400,
          end: 500
        }, {
          start: 500,
          end: 600
        }, {
          start: 600,
          end: 700
        }, {
          start: 700,
          end: 800
        }, {
          start: 800,
          end: 900
        }, {
          start: 900,
          end: 1000
        }, {
          start: 1000
        }
      ],
      color: ['#dd5e1a'] //自定义范围的颜色
    },
    geo: {
      map: "zhejiang",
      aspectScale: 0.9,
      zoom: 1.1,
      // 底层添加边框
      itemStyle: {
        borderColor: "#603131",
        borderWidth: 2,
        borderType: "solid"
      },
    },
    series: [{
      type: "map",
      map: "zhejiang",
      aspectScale: 0.9,
      zoom: 1.1,
      label: {
        fontFamily: "PingFangSC-Medium",
        fontSize: 14,
        color: "#FFFFFF",
        textAlign: "justify",
        fontWeight: 500,
        textBorderColor: "#060707",
        textBorderWidth: 1.4,
        show: true // 显示
      },
      select: {
        label: {
          color: '#fff',
        },
        itemStyle: {
          areaColor: '#D04318',
        },
      },
      // 数据
      data: [{
        name: '杭州',
        value: '1202'
      }, {
        name: '温州',
        value: '901'
      }, {
        name: '绍兴',
        value: '801'
      }, {
        name: '宁波',
        value: '796'
      }, {
        name: '舟山',
        value: '625'
      }, {
        name: '嘉兴',
        value: '535'
      }, {
        name: '湖州',
        value: '486'
      }, {
        name: '台州',
        value: '360'
      }, {
        name: '金华',
        value: '231'
      }, {
        name: '衢州',
        value: '196'
      }, {
        name: '丽水',
        value: '80'
      }]
    }]
  };
  return option;
}
